<template>
  <view class="group-button">
    <!-- 组团邀请人 -->
    <!-- 未成团无团员 -->
    <finishButton
      v-if="isShowTeamLeader"
      class="big-button-invitational"
      @click="handleJoinGroup('team-leader')"
    >
      我要当团长
    </finishButton>
    <!-- 未成团有团员 -->
    <view
      v-if="hasGroup && isInGroup && !fullGroup"
      class="not-group-has-number"
    >
      <finishButton
        :width="300"
        class="small-button-punch"
        data-type="punch"
        :backgroundBg="smallButtonBg"
        @click="handleJoinGroup('punch')"
      >
        打卡
      </finishButton>
      <finishButton
        :width="300"
        data-type="invite"
        class="small-button-invitation"
        :backgroundBg="smallRedButtonBg"
        @click="handleJoinGroup('invite')"
      >
        邀请好友入团
      </finishButton>
    </view>
    <!-- 满团只能打卡 -->
    <finishButton
      v-if="isShowSingleBtn"
      :width="600"
      class="full-group-button"
      @click="handleJoinGroup('punch')"
    >
      打卡
    </finishButton>
    <!-- 被邀请人 -->
    <!-- Invitees -->
    <finishButton
      v-if="isShowInGroup"
      class="big-button-Invitees"
      @click="handleJoinGroup('in-group')"
    >
      立即入团
    </finishButton>
  </view>
</template>
<script>
import finishButton from "@/components/finish-button/index";
import { smallButtonBg } from "@/libs/image-url";
import {
  NOT_GROUP,
  DONE_GROUP,
  FULL_GROUP,
  OVER_ACTIVITY
} from "@/config/base-common";
/**邀请好友按钮背景 */
const smallRedButtonBg =
  "https://xthk.oss-cn-shenzhen.aliyuncs.com/teach/1607072957859_0.5049523968429337_%E6%8C%89%E9%92%AE%402x.png";
export default {
  props: {
    /**是否有团 */
    hasGroup: {
      type: Boolean,
      default: false
    },
    /**是否在团中 */
    isInGroup: {
      type: Boolean,
      default: false
    },
    fullGroup: {
      type: Boolean
    }
  },
  components: {
    finishButton
  },
  data() {
    return {
      smallButtonBg,
      smallRedButtonBg
    };
  },
  computed: {
    /**是否展示我要当团长按钮 */
    isShowTeamLeader() {
      return !this.hasGroup || (this.fullGroup && !this.isInGroup);
    },
    /**是否展示立即入团 */
    isShowInGroup() {
      return this.hasGroup && !this.isInGroup && !this.fullGroup;
    },
    /**是否单个打卡按钮 */
    isShowSingleBtn() {
      return this.hasGroup && this.fullGroup && this.isInGroup;
    }
  },
  methods: {
    handleJoinGroup(type) {
      this.$emit("punch-operat", type);
    }
  }
};
</script>
<style lang="scss">
@import "../scss/group-common.scss";
.group-button {
  position: relative;
  @mixin base-button-style($w: 600px) {
    width: $w;
    height: 88px;
    text-align: center;
    font-size: 32px;
    font-family: PingFang SC;
    font-weight: bold;
    line-height: 88px;
    color: #ffffff;
  }
  @mixin base-more-tips($t: -24px, $r: -18px) {
    content: "更多奖励";
    position: absolute;
    top: $t;
    right: $r;
    width: 146px;
    background-image: url("../../../../assets/icon/more-button.png");
    background-size: 100% 100%;
    @include base-text(54px, 24px, #a13d0f);
    line-height: 50px;
    text-align: center;
  }
  .full-group-button {
    margin-left: 12px;
    @include base-button-style();
  }

  .big-button-invitational {
    margin-left: 12px;
    @include base-button-style();
    &::after {
      @include base-more-tips();
    }
  }
  .big-button-Invitees {
    margin-left: 14px;
  }
  .not-group-has-number {
    display: flex;
    .small-button-punch {
      margin-right: 26px;
    }
    .small-button-invitation {
      &::after {
        @include base-more-tips(-24px, -6px);
      }
    }
  }
}
</style>
